<template>
  <div class="post-card card">
    <h2 class="post-title">
      <router-link :to="`/blog/${post.id}`">{{ post.title }}</router-link>
    </h2>
    <div class="post-meta">
      <span>{{ formatDate(post.createdAt) }}</span>
      <span class="meta-divider">|</span>
      <span>{{ post.author }}</span>
    </div>
    <div class="post-summary">{{ post.summary }}</div>
    <div class="post-footer">
      <router-link :to="`/blog/${post.id}`" class="read-more">
        阅读全文 <el-icon><arrow-right /></el-icon>
      </router-link>
    </div>
  </div>
</template>

<script setup>
import { ArrowRight } from '@element-plus/icons-vue'

const props = defineProps({
  post: {
    type: Object,
    required: true
  }
})

const formatDate = (dateString) => {
  const date = new Date(dateString)
  return date.toLocaleDateString('zh-CN', {
    year: 'numeric',
    month: 'long',
    day: 'numeric'
  })
}
</script>

<style lang="less" scoped>
.post-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }
}

.post-title {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 22px;
  
  a {
    color: #303133;
    text-decoration: none;
    
    &:hover {
      color: #409eff;
    }
  }
}

.post-meta {
  color: #909399;
  font-size: 14px;
  margin-bottom: 15px;
  
  .meta-divider {
    margin: 0 8px;
  }
}

.post-summary {
  color: #606266;
  margin-bottom: 20px;
  line-height: 1.6;
}

.post-footer {
  display: flex;
  justify-content: flex-end;
}

.read-more {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #409eff;
  text-decoration: none;
  font-size: 14px;
  
  &:hover {
    text-decoration: underline;
  }
}
</style>

